import VueRouter from "vue-router";
import Index from "@/views/Index.vue";
const router = new VueRouter({
  routes: [
    // 首页
    {
      path: "/",
      name: "Index",
      component: Index,
    },
    // 产品页
    {
      path: "/product/:id",
      name: "product",
      // 路由懒加载，当我展示对应的路由的时候才加载对应的文件，可以解决 首页白屏
      //webpack魔法注释，将来打包的时候会把product组件单独打包成一个js，去到对应的路由才会加载，减轻服务器压力
      component: () =>
        import(/* webpackChunkName:"product" */ "../views/Product.vue"),
    },
    // 详细页
    {
      path: "/detail/:id",
      name: "detail",
      component: () =>
        import(/* webpackChunkName:"detail" */ "../views/Detail.vue"),
    },
    // 购物车页
    {
      path: "/cart",
      name: "cart",
      component: () =>
        import(/* webpackChunkName:"cart" */ "../views/Cart.vue"),
    },
    // 登陆
    {
      path: "/login",
      name: "login",
      component: () =>
        import(/* webpackChunkName:"login" */ "../views/Login.vue"),
    },
     // 注册
     {
      path: "/register",
      name: "register",
      component: () =>
        import(/* webpackChunkName:"login" */ "../views/Register.vue"),
    },
    //订单页面
    {
      path: "/",
      name: "order",
      component: () =>
        import(/* webpackChunkName:"order" */ "../views/Order.vue"),
      redirect:'/orderconfirm',
      children: [
        //重新定向
        // {
        //   path:"*",
        //   
        // },
        // 订单确认
        {
          path: "orderconfirm",
          name: "orderconfirm",
          component: () =>
            import(
              /* webpackChunkName:"orderconfirm" */ "../views/OrderConfirm.vue"
            ),
        },
       
       
      ],
    },
     // 订单支付
     {
      path: "/orderpay",
      name: "orderpay",
      component: () =>
        import(/* webpackChunkName:"orderpay" */ "../views/OrderPay.vue"),
    },
     // 订单列表
     {
      path: "/orderlist",
      name: "orderlist",
      component: () =>
        import(/* webpackChunkName:"orderlist" */ "../views/OrderList.vue"),
    },
  ],
});
export default router;
